﻿using Microsoft.AspNetCore.Mvc;
using ServiceCore.Entity.Core;
using ServiceCore.Entity.Dto;
using ServiceCore.Entity.Model;
using ServiceCore.Entity.Param.Tag;
using ServiceCore.Service;
using ServiceCore.WebApi.jwt;

namespace ServiceCore.WebApi.Controllers
{
    /// <summary>
    /// 标签
    /// </summary>
    [Route("Api/[controller]/[action]")]
    [ApiController]
    public class TagController : ApiJwtController
    {
        private TagService tagService = new TagService();

        /// <summary>
        /// 列表
        /// </summary>
        /// <arg name="arg"></arg>
        /// <returns></returns>
        [HttpPost]
        public BaseParam<TagInfo, List<TagInfo>> List(BaseParam<TagInfo, List<TagInfo>> arg)
        {
            arg = tagService.Tag_List(arg);

            return arg;
        }

        /// <summary>
        /// 下拉框
        /// </summary>
        /// <arg name="arg"></arg>
        /// <returns></returns>
        [HttpPost]
        public BaseParam<RecordInfo, List<DownBoxDto>> DownBox(BaseParam<RecordInfo, List<DownBoxDto>> arg)
        {
            arg = tagService.Tag_DownBox(arg);

            return arg;
        }
        

        /// <summary>
        /// 新增
        /// </summary>
        /// <arg name="arg"></arg>
        /// <returns></returns>
        [HttpPost]
        public BaseParam<TagInfo, long> Add(BaseParam<TagInfo, long> arg)
        {
            var userInfo = GetJwtUserInfo();
            arg.Param.CreateUserId = userInfo.Id;
            arg = tagService.Tag_Add(arg);

            return arg;
        }

        /// <summary>
        /// 编辑
        /// </summary>
        /// <arg name="arg"></arg>
        /// <returns></returns>
        [HttpPost]
        public BaseParam<TagInfo, long> Edit(BaseParam<TagInfo, long> arg)
        {
            arg = tagService.Tag_Edit(arg);

            return arg;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <arg name="arg"></arg>
        /// <returns></returns>
        [HttpPost]
        public BaseParam<TagDeleteParam, long> Del(BaseParam<TagDeleteParam, long> arg)
        {
            arg = tagService.Tag_Delete(arg);

            return arg;
        }
    }
}
